import matplotlib.pyplot as plt

# 文件名
filename = 'pitch_pid.txt'
data_name = 'pitch_analg:'

# 读取文件中的数据
yaw_values = []
with open(filename, 'r') as file:
    for line in file:
        line = line.strip()  # 去除行首尾的空白字符
        if line.startswith(str(data_name)):
            yaw_value = float(line.split(':')[1])  # 提取yaw值并转换为浮点数
            yaw_values.append(yaw_value)

# 绘制曲线
plt.figure(figsize=(10, 5))  # 设置图形大小
plt.plot(yaw_values, marker='o', linestyle='-', color='blue')  # 绘制曲线，并设置标记和线条样式
plt.title('Analog Values from ' + str(data_name))  # 设置图形标题
plt.xlabel('Sample Index')  # 设置x轴标签
plt.ylabel(data_name)  # 设置y轴标签
plt.grid(True)  # 显示网格线
plt.show()  # 显示图形